--- CS-011-09
---

--1.-

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK__T013__T011Entity__0C85DE4D]') AND parent_object_id = OBJECT_ID(N'[dbo].[T013]'))
ALTER TABLE [dbo].[T013] DROP CONSTRAINT [FK__T013__T011Entity__0C85DE4D]
GO

--2.-

ALTER TABLE [dbo].[T013] ADD 
	FOREIGN KEY ([T011Entity])
		REFERENCES [dbo].[T011]([T011Entity])
		ON DELETE CASCADE
		ON UPDATE CASCADE
GO

--3.-
-- SELECT * FORM T014 , obtener folio actual de clientes
--INSERT INTO T014(T014IdParametro,T014Val1) VALUES ('FOLENTITY',15)

DECLARE @T027IdScript as varchar(80)
DECLARE @T027Descripcion as varchar(360)
SET @T027IdScript='CS-011-09'
SET @T027Descripcion='Se modifica la relacion de las tablas T011 y T013'
INSERT INTO T027(T027IdScript,T027Descripcion,T027FechaRealizado) VALUES (@T027IdScript,@T027Descripcion,getdate())